import { IPSDataEntity } from '../dataentity/ipsdata-entity';
import { IPSSysTestData } from './ipssys-test-data';
import { IPSSysTestDataItem } from './ipssys-test-data-item';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSSysTestDataImpl extends PSModelObjectImpl implements IPSSysTestData {
  get codeName(): string {
    return this.M.codeName;
  }

  get data(): string {
    return this.M.data;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get instCount(): number {
    return this.M.instCount;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psdataentity: IPSDataEntity | null = null;

  getPSDataEntity(): IPSDataEntity | null {
    if (this.psdataentity != null) return this.psdataentity;
    const value = this.M.getPSDataEntity;
    if (value == null) {
      return null;
    }
    this.psdataentity = this.getPSModel4('dataentity.IPSDataEntity', value, 'getPSDataEntity') as IPSDataEntity;
    return this.psdataentity;
  }

  get psDataEntity(): IPSDataEntity | null {
    return this.getPSDataEntity();
  }

  getPSDataEntityMust(): IPSDataEntity {
    const value = this.getPSDataEntity();
    if (value == null) {
      throw new Error('未指定相关实体');
    }
    return value;
  }

  protected pssystestdataitems: IPSSysTestDataItem[] | null = null;

  getPSSysTestDataItems(): IPSSysTestDataItem[] | null {
    if (this.pssystestdataitems == null) {
      this.pssystestdataitems = this.fillChildListModel(this.M.getPSSysTestDataItems, 'testing.IPSSysTestDataItem') as IPSSysTestDataItem[];
    }
    return this.pssystestdataitems;
  }

  get psSysTestDataItems(): IPSSysTestDataItem[] | null {
    return this.getPSSysTestDataItems();
  }

  findPSSysTestDataItem(objKey: any): IPSSysTestDataItem | null {
    return this.getPSModel5('testing.IPSSysTestDataItem', this.getPSSysTestDataItems(), objKey) as IPSSysTestDataItem;
  }

  get scriptCode(): string {
    return this.M.scriptCode;
  }

  get testDataType(): 'DATA' | 'CUSTOMCODE' | 'USER' | 'USER2' | 'USER3' | 'USER4' {
    return this.M.testDataType;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get baseMode(): boolean {
    return this.M.baseMode;
  }

  get cls(): string {
    return 'PSSysTestDataImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'testing.IPSSysTestData') return true;
    return super.instanceof(cls);
  }
}
